Skip to content

Fix model generation, decimal inputs and Badge variants; use ruby_ui 1.6 from RubyGems - #2

Merged
jacksonpires merged 1 commit into
mainfrom
fix/ruby-ui-1.6-compat
Nov 13, 2026
Merged

jacksonpires merged 1 commit into
mainfrom
fix/ruby-ui-1.6-compat

Conversation

@jacksonpires

Copy link
Copy Markdown
Owner

Summary

Compatibility check against ruby_ui 1.6.0 (latest). Every component and kwarg the templates use exists in 1.6.0, but an end-to-end run in a fresh Rails 8.1 app found three bugs in this gem. None of them is caused by ruby_ui 1.6.

Fixed

  • rails g ruby_ui_scaffold generated no model or migration. Having the gem in the Gemfile also broke plain rails g model. The Railtie's generators block required generator classes, and Rails runs those blocks before Rails::Generators.configure!. That loaded ModelGenerator early and froze its :orm hook as false. The Railtie now only sets option defaults, and the classes load lazily. Because Rails' hook lookup requires only the first existing candidate file, the entry generator now requires its sub-generators. Without that, the views hook reports ruby_ui_scaffold [not found].
  • The edit form crashed for decimal columns with Phlex::ArgumentError (Invalid attribute value for value: 0.58206e3). Phlex 2 rejects BigDecimal attribute values, so the value is now &.to_s, which renders as "582.06".
  • Boolean Badge had no colors. Variants were passed as strings, but RubyUI::Badge::COLORS is symbol-keyed, so they are now :success / :outline.

Changed

  • The installer now adds gem "ruby_ui", "~> 1.6", require: false from RubyGems instead of the GitHub main branch. Existing GitHub entries are still detected and left alone.

Test plan

  • rake test: 122 runs, 0 failures
  • New test/railtie_test.rb boots a minimal app in a subprocess through the real load_generators path. It asserts the :orm default and resolves the sub-generators the same way the hooks do. Confirmed it fails both without the Railtie fix and without the sub-generator requires.
  • End-to-end in a fresh Rails 8.1 app with no ruby_ui in the Gemfile:
    • The install bootstrapped ruby_ui 1.6.0 from RubyGems.
    • Two scaffolds were generated, one with --datatable covering string, text, decimal, float, integer, boolean, date, datetime and references.
    • seed worked.
    • index (including search, sort and pagination), show, new and edit all returned 200; create, update and destroy all succeeded.
    • --skip-model re-runs worked.

🤖 Generated with Claude Code

…from RubyGems

- Railtie no longer requires generator classes in its `generators` block.
  Rails runs those blocks before `Rails::Generators.configure!`, so loading
  Rails' ModelGenerator there froze its `:orm` hook as `false` and
  `rails g ruby_ui_scaffold` (and plain `rails g model`) skipped the model
  and migration. The entry generator now requires its sub-generators, since
  Rails' hook lookup only loads the first matching candidate file.
- Stringify decimal input values: Phlex 2 rejects BigDecimal attributes,
  which crashed the edit form.
- Pass Badge variants as symbols; RubyUI::Badge::COLORS is symbol-keyed, so
  string variants rendered without colors.
- Installer adds `gem "ruby_ui", "~> 1.6"` from RubyGems instead of the
  GitHub main branch. Verified end-to-end against ruby_ui 1.6.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jacksonpires
jacksonpires merged commit 49a4171 into main Nov 13, 2026
16 checks passed
@jacksonpires
jacksonpires deleted the fix/ruby-ui-1.6-compat branch November 13, 2026 01:54
@jacksonpires jacksonpires mentioned this pull request Nov 13, 2026
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant